#ifndef QIZI_H
#define QIZI_H

#include<QString>

class qizi
{
public:
    qizi();

    enum TYPE{CHE,MA,JIANG,PAO,BING,SHI,XIANG};


    int row;
    int column;
    //棋子坐标
    int location;
    //棋子之前的位置
    bool dead;
    //棋子是否被吞
    bool color;
    //棋子颜色
    TYPE type;
    //棋子类型：将相车马炮兵士
    void init(int loc){
        struct{
        int row,column;
        qizi::TYPE type;
        }pos[16]={
        {0,0,qizi::CHE},
        {0,1,qizi::MA},
        {0,2,qizi::XIANG},
        {0,3,qizi::SHI},
        {0,4,qizi::JIANG},
        {0,5,qizi::SHI},
        {0,6,qizi::XIANG},
        {0,7,qizi::MA},
        {0,8,qizi::CHE},
        {2,1,qizi::PAO},
        {2,7,qizi::PAO},
        {3,0,qizi::BING},
        {3,2,qizi::BING},
        {3,4,qizi::BING},
        {3,6,qizi::BING},
        {3,8,qizi::BING},
        };
        location=loc;
        dead=false;
        color=loc<16;
        if(loc<16){
            row=pos[loc].row;
            column=pos[loc].column;
            type=pos[loc].type;
        }
        else{
            row=9-pos[loc-16].row;
            column=8-pos[loc-16].column;
            type=pos[loc-16].type;
        }
    }
   QString getText(){
        switch(this->type){
        case CHE:
            return "车";
        case MA:
            return "马";
        case JIANG:
            return "将";
        case PAO:
            return "炮";
        case BING:
            return "兵";
        case SHI:
            return "仕";
        case XIANG:
            return "相";
        }

    }
};

#endif // QIZI_H
